<?php
require_once 'cmClasses/trunk/autoload.php5';
require_once 'A.php5';

$template	= '
<div>
	<div id="tree"><%?tree%></div>
	<div id="content">
		<div>
			<table>
				<tr>
					<td colspan="3"></td>
				</tr>
				<tr>
					<td colspan="3"></td>
				</tr>
				<tr>
					<td></td>
					<td></td>
					<td></td>
				</tr>
			</table>
			<div id="test-errors"></div>
			<div id="test-failures"></div>
		</div>
		<div id="layer-processing"></div>
	</div>
</div>
<script>
	
/*	
	public function getErrors()
	{
		$list	= array();
		foreach( $this->tree->children() as $testSuite )
			$this->getMessagesRecursive( $testSuite, $list, "error" );
		return $list;
	}
	
	private function getMessagesRecursive( SimpleXMLElement $element, &$list, $type, $testSuite = "" )
	{
		if( $element->getName() == "testcase" && $element->$type )
		{
			return $list[]	= array(
				"suite"		=> $testSuite,
				"case"		=> $element->getAttribute( "name" ),
				"error"		=> $element->$type,
				"type"		=> $element->$type->getAttribute( "type" ),
			);
		}
		foreach( $element->children() as $child )
			$this->getMessagesRecursive( $child, $list, $type, $element->getAttribute( "name" ) );
	}

	public function getFailureCount()
	{
		return $this->tree->testsuite[0]->getAttribute( "failures" );
	}
	
	public function getFailures()
	{
		$list	= array();
		foreach( $this->tree->children() as $testSuite )
			$this->getMessagesRecursive( $testSuite, $list, "failure" );
		return $list;
	}
		
	public function getTestCount()
	{
		return $this->tree->testsuite[0]->getAttribute( "tests" );
	}
	
	public function getTestSuiteCount( $element = NULL )
	{
		$count		= 1;
		$element	= $element === NULL ? $this->tree : $element;
		foreach( $element->testsuite as $testSuite )
			$count	+= $this->getTestSuiteCount( $testSuite );
		return $count;
	}
	
	public function getTestCaseCount( $element = NULL )
	{
		$count		= 0;
		$element	= $element === NULL ? $this->tree : $element;
		foreach( $element->testsuite as $testSuite )
			$count	+= $this->getTestCaseCount( $testSuite );
		$count	+= count( $element->testcase );
		return $count;
	}
	
	public function getTime()
	{
		return $this->tree->testsuite[0]->getAttribute( "time" );
	}
*/

$(document).ready(function(){

	$("#tree li span").each(function(){
		$(this).bind("click",function(){
			var path = $(this).parent().attr("data-uri");
			console.log(path);
			requestTestResults(path);
		});
	});
//	$("li#node-Test_Alg_Text_TermExtractorTest>span").trigger("click");
//	$("li#node-Test_Alg_Validation_LanguageValidatorTest>span").trigger("click");
	$("li#node-Test_ADT_List>span").trigger("click");

});
</script>
';

$pathBase	= '/var/www/lib/cmClasses/trunk/';
$pathTest	= 'Test';

new A( $pathBase, $pathTest, $template );

?>
